home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagn_r.zip / NETWORK.SWG / 0003_GET-ID2.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  2KB  |  67 lines

  1. {
  2. >  Okay, here goes.  I am using Borland Pascal 7.0 under MS-Dos 5.0.
  3. >Basically, the Program I am writing will be run under Novell Netware
  4. >3.11.  What I need to do is determine the User's full user name.  I
  5. >could do this using Novell Interrupts, but they are impossible to figure
  6. >out (At least For me).  So what I wanted to do, was use Novell's
  7. >"WHOAMI" command.  What this does is return the user's full name and
  8.  
  9. Well, I think you'll find it harder to to a Dos exec and parse the output after
  10. reading it from a File than asking Netware what it is.  Plus you must depend on
  11. the user having access to use the command.  I'm on some Novell networks where
  12. that command File is not present because it wasn't considered important.
  13. Here's how to get the user name from Netware...
  14. }
  15. Program UserID;
  16.  
  17. Uses
  18.   Dos, Strings;
  19.  
  20. Type
  21.   RequestBuf = Record
  22.     RequestLen    : Word; { Number of Bytes in the rest of the Record }
  23.     SubFunction   : Byte; { Function from Novell we are requesting }
  24.     ConnectionNum : Byte; { Connection number that is making the call }
  25.   end;
  26.  
  27.   ReplyBuf = Record
  28.     ReplyLength : Word;    { Number of Bytes in the rest of the Record }
  29.     ObjectId    : LongInt; { Novell refers to everything by Objects like users}
  30.     ObjectType  : Word;
  31.     ObjectName  : Array[1..48] of Char;
  32.     LoginTime   : Array[1..7] of Char;
  33.   end;
  34.  
  35. Var
  36.   I:Word;
  37.   ReqBuf   : RequestBuf;
  38.   RepBuf   : ReplyBuf;
  39.   Regs     : Registers;
  40.   UserName : String[48];
  41.  
  42. begin
  43.   Regs.AH := $DC;
  44.   MsDos(Regs); { Get the connection number }
  45.  
  46.   ReqBuf.RequestLen    := 2;        { User ID request, must give connection }
  47.   ReqBuf.SubFunction   := $16;      { number                                }
  48.   ReqBuf.ConnectionNum := Regs.AL;
  49.  
  50.   RepBuf.ReplyLength := 61; { Return buffer For name }
  51.  
  52.   Regs.AH := $E3;         { Call Novell For user name }
  53.   Regs.DS := Seg(ReqBuf); { Passing it the request buffer indicating }
  54.   Regs.SI := Ofs(ReqBuf); { the data we want and a reply buffer to send }
  55.   Regs.ES := Seg(RepBuf); { us back the information }
  56.   Regs.DI := Ofs(RepBuf);
  57.   MsDos(Regs);
  58.  
  59.   { Object name now contians the users ID, use the StringS Unit Functions }
  60.   { to print the null-terminated String }
  61.   WriteLn(StrPas(@RepBuf.ObjectName));
  62. end.
  63.  
  64. {
  65. That will read in a Novell User ID For you.
  66. }
  67.